function SE_open(A, B){
    var U = document.location.href;
    A = A.replace('[-TITLE-]', encodeURIComponent(document.title));
    A = A.replace('[-URL-]', encodeURIComponent([U, U.indexOf('?') == -1 ? '?' : '&', 'utm_source=', B, '&utm_medium=share&utm_content=', document.domain, '&utm_campaign=Share'].join('')));
    window.open(A, '_blank', 'scrollbars=no,width=600,height=450,left=' + (screen.width - 600) / 2 + ',top=' + (screen.height - 450) / 2 + ',status=no,resizable=yes');
}

function SE_sina(){
    SE_open('http://v.t.sina.com.cn/share/share.php?url=[-URL-]&title=[-TITLE-]&source=EDUU&sourceUrl=http%3A%2F%2F' + document.domain + '%2F&content=gb2312&pic=' + (sendT.getFirstImgSrc() || ''), 'Sina')
}

function SE_baidu(){
    SE_open('http://cang.baidu.com/do/add?it=[-TITLE-]&iu=[-URL-]&fr=ien#nw=1', 'baidu')
}

function SE_qq(){
    SE_open('http://shuqian.qq.com/post?title=[-TITLE-]&uri=[-URL-]&jumpback=2&noui=1', 'QQ')
}

function SE_ranran(){
    SE_open('http://share.renren.com/share/buttonshare.do?link=[-URL-]&amp;title=[-TITLE-]', 'renren')
}

function SE_kaixin(){
    var url = 'http://www.kaixin001.com/repaste/bshare.php?rtitle=' + encodeURIComponent(document.title) + '&amp;rurl=' + encodeURIComponent(location.href) + '&amp;from=maxthon';
    var tempForm = document.createElement('form');
    tempForm.id = '_tempFm';
    tempForm.method = 'post';
    tempForm.action = url;
    tempForm.target = '_blank';
    var hideInput = document.createElement('input');
    hideInput.type = 'hidden';
    hideInput.name = 'rcontent';
    hideInput.value = sendT.getContent();
    tempForm.appendChild(hideInput);
    document.body.appendChild(tempForm);
    tempForm.submit();
    document.body.removeChild(tempForm)
}

var sendT = {
    getHeader: function(){
        var g_title = document.getElementsByTagName("h1")[0].innerHTML;
        var re = /<[^<>]*?font[^<>]*?>/gi;
        g_title = g_title.replace(re, "");
        return g_title
    },
    getFirstImgSrc: function(){
        var allPageTags = document.getElementsByTagName("div");
        for (var i = 0; i < allPageTags.length; i++) {
            if (allPageTags[i].className == 'content_txt') {
                if (allPageTags[i].getElementsByTagName("img")[0] && allPageTags[i].getElementsByTagName("img")[0].width > 100) {
                    return allPageTags[i].getElementsByTagName("img")[0].src
                }
                else {
                    return null
                }
            }
        }
    },
    getContent: function(){
        var d = document;
        var data = d.selection ? (d.selection.type != 'None' ? d.selection.createRange().text : '') : (d.getSelection ? d.getSelection() : '');
        if (!data) {
            var allPageTagss = document.getElementsByTagName("div");
            for (var i = 0; i < allPageTagss.length; i++) {
                if (allPageTagss[i].className == 'content_txt') {
                    data = allPageTagss[i].innerHTML;
                    break
                }
                else 
                    if (allPageTagss[i].className == 'content') {
                        data = allPageTagss[i].getElementsByTagName("P")[0].innerHTML;
                        break
                    }
            }
            data = data.replace(/<[^><]*?>/g, '');
            data = data.replace(/<!--(.*)-->/g, '');
            data = data.replace(/[\n]/g, '[-br-]');
            data = data.replace(/[\s]+/g, '');
            data = data.replace(/(\[-br-\])+/g, "\n    ")
        }
        return data
    }
}

eShare = '<a class="icon-sina" href="javascript:void(0);" onclick="SE_sina()" onmousedown = "hits(\'content06\')"><img src="/img/ico_sina.gif" /></a>' +
'<a class="icon-qq" href="javascript:void(0);" onclick="SE_qq()" onmousedown = "hits(\'content07\')"><img src="/img/ico_qzone.gif" /></a>' +
'<a class="icon-renren" href="javascript:void(0);" onclick="SE_ranran()" onmousedown = "hits(\'content08\')"><img src="/img/ico_ren.gif" /></a>' +
'<a class="icon-kaixin" href="javascript:void(0);" onclick="SE_kaixin()" onmousedown = "hits(\'content09\')"><img src="/img/ico_kaixin.gif" /></a>';
document.writeln(eShare);
